﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DeployGames.TweenEngine.equations
{
    public abstract class Quad : TweenEquation
    {
        public static QuadIN IN = new QuadIN();
        public static QuadOUT OUT = new QuadOUT();
        public static QuadINOUT INOUT = new QuadINOUT();

        #region QuadIN
        public class QuadIN : Quad
        {
            public override float compute(float t)
            {
                return t * t;
            }

            public override string ToString()
            {
                return "Quad.IN";
            }
        }
        #endregion

        #region QuadOUT
        public class QuadOUT : Quad
        {
            public override float compute(float t)
            {
                return -t * (t - 2);
            }

            public override string ToString()
            {
                return "Quad.OUT";
            }
        }
        #endregion

        #region QuadINOUT
        public class QuadINOUT : Quad
        {
            public override float compute(float t)
            {
                if ((t *= 2) < 1) return 0.5f * t * t;
                return -0.5f * ((--t) * (t - 2) - 1);
            }

            public override string ToString()
            {
                return "Quad.INOUT";
            }
        }
        #endregion
    }
}
